Skip to content

feat: forward txs to sequencer #1208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Jul 14, 2025
Merged

Conversation

yiweichi
Copy link
Member

@yiweichi yiweichi commented Jun 19, 2025

1. Purpose or design rationale of this PR

This PR add feature to enable RPC node forward transactions directly to sequencer.
txgossip.sequencerhttp: the sequencer's http rpc endpoint

2. PR title

Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:

  • build: Changes that affect the build system or external dependencies (example scopes: yarn, eslint, typescript)
  • ci: Changes to our CI configuration files and scripts (example scopes: vercel, github, cypress)
  • docs: Documentation-only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that doesn't fix a bug, or add a feature, or improves performance
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • test: Adding missing tests or correcting existing tests

3. Deployment tag versioning

Has the version in params/version.go been updated?

  • This PR doesn't involve a new deployment, git tag, docker image tag, and it doesn't affect traces
  • Yes

4. Breaking change label

Does this PR have the breaking-change label?

  • This PR is not a breaking change
  • Yes

Summary by CodeRabbit

  • New Features

    • Introduced new CLI flag to configure sequencer HTTP endpoint for transaction gossip.
    • Added support for forwarding transactions to a remote sequencer via HTTP.
    • Enabled configuration options to control transaction gossip broadcasting and receiving behavior.
  • Bug Fixes

    • Transactions of unsupported types are now correctly rejected.
  • Chores

    • Updated the application patch version to 67.

Copy link

coderabbitai bot commented Jun 19, 2025

Walkthrough

This update introduces a new CLI flag for configuring a sequencer HTTP endpoint used in transaction gossiping. It extends the Ethereum backend to optionally forward transactions to a remote sequencer RPC service and conditionally disables local transaction pool persistence. Additional transaction gossip control flags and related configuration fields are added, along with version bumping.

Changes

File(s) Change Summary
cmd/geth/main.go, cmd/geth/usage.go Added new TxGossipSequencerHTTPFlag CLI flag to node flags and usage groups.
cmd/utils/flags.go Renamed txgossip flags prefix to gossip; added new gossip.sequencerhttp CLI flag; updated SetEthConfig to conditionally set sequencer HTTP config when mining disabled.
eth/ethconfig/config.go Added TxGossipBroadcastDisabled, TxGossipReceivingDisabled, and TxGossipSequencerHTTP fields to Config struct.
eth/backend.go Added sequencerRPCService RPC client field; updated constructor to initialize gossip flags and sequencer RPC client; closed client on stop.
eth/api_backend.go Added disableTxPool field; modified SendTx to forward transactions to sequencer RPC; conditionally skip local pool; added helper method.
params/version.go Incremented patch version constant from 65 to 67.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Node
    participant EthAPIBackend
    participant SequencerRPC
    participant TxPool

    User->>CLI: Start node with sequencer HTTP flag
    CLI->>Node: Initialize with config
    Node->>EthAPIBackend: Pass gossip flags and sequencer endpoint

    User->>EthAPIBackend: SendTx(signedTx)
    EthAPIBackend->>EthAPIBackend: Check tx type
    alt BlobTxType
        EthAPIBackend-->>User: Return error
    else sequencerRPC configured
        EthAPIBackend->>EthAPIBackend: AddLocal(tx)
        alt AddLocal fails
            EthAPIBackend-->>User: Return error
        else
            EthAPIBackend->>SequencerRPC: Forward tx via eth_sendRawTransaction
            alt Forwarding fails and disableTxPool
                EthAPIBackend-->>User: Return error
            else Forwarding fails but disableTxPool false
                EthAPIBackend-->>User: Return success (log warning)
            else Forwarding succeeds
                EthAPIBackend-->>User: Return success
            end
        end
    else
        EthAPIBackend->>TxPool: AddLocal(tx)
        EthAPIBackend-->>User: Return result/error
    end
Loading

Possibly related PRs

Suggested reviewers

  • georgehao
  • Thegaram

Poem

A flag appears, a gateway bright,
To sequencer’s HTTP light.
Transactions hop, some sent afar,
Others stay local, near or far.
Configs set, the patch now done,
A rabbit’s leap, the code has run! 🐇🚀


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 035a10f and 5261fb2.

📒 Files selected for processing (5)
  • cmd/geth/main.go (1 hunks)
  • cmd/geth/usage.go (1 hunks)
  • cmd/utils/flags.go (2 hunks)
  • eth/api_backend.go (4 hunks)
  • eth/backend.go (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • cmd/geth/usage.go
  • cmd/geth/main.go
  • eth/backend.go
  • cmd/utils/flags.go
🧰 Additional context used
🧠 Learnings (1)
eth/api_backend.go (1)
Learnt from: Thegaram
PR: scroll-tech/go-ethereum#1204
File: miner/scroll_worker.go:836-845
Timestamp: 2025-06-11T15:54:05.820Z
Learning: When `processTxn` rejects a transaction because its calculated L1 data fee is ≥ `fees.MaxL1DataFee()`, this indicates a mis-configured system parameter, not a bad transaction, so the tx must remain in the TxPool rather than being purged.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (go)
🔇 Additional comments (5)
eth/api_backend.go (5)

28-28: LGTM: Required imports added for new functionality.

The hexutil import is needed for encoding transaction data when forwarding to the sequencer, and log import is needed for logging warnings during sequencer forwarding failures.

Also applies to: 39-39


49-49: LGTM: New field supports transaction pool control.

The disableTxPool field enables conditional transaction pool behavior, which is essential for the verifier mode operation mentioned in the PR objectives.


272-276: LGTM: Local pool addition moved to front with proper error handling.

The implementation now adds transactions to the local pool first, with immediate error return on failure. This addresses the previous review feedback about transaction validation and ordering.


278-290: LGTM: Sequencer forwarding logic with improved error handling.

The sequencer forwarding implementation correctly:

  • Serializes the transaction using MarshalBinary()
  • Uses the eth_sendRawTransaction RPC method
  • Logs forwarding failures appropriately
  • Returns errors only when disableTxPool is true

This addresses the previous concerns about error suppression and transaction flow.


295-298: LGTM: Clean helper method extraction.

The sendTx helper method properly encapsulates the local transaction pool addition logic, making the code more maintainable and following the single responsibility principle.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🔭 Outside diff range comments (1)
eth/handler.go (1)

442-444: Fix potential nil pointer dereference in Stop method.

The Stop method unconditionally calls h.txsSub.Unsubscribe(), but h.txsSub will be nil when disableTxBroadcast is true since the subscription is not created in that case.

Add a nil check to prevent panic:

 func (h *handler) Stop() {
-	h.txsSub.Unsubscribe()        // quits txBroadcastLoop
+	if h.txsSub != nil {
+		h.txsSub.Unsubscribe()    // quits txBroadcastLoop
+	}
 	h.minedBlockSub.Unsubscribe() // quits blockBroadcastLoop
🧹 Nitpick comments (1)
eth/backend.go (1)

311-319: Consider making the connection timeout configurable.

The hardcoded 5-second timeout for the sequencer RPC connection may be insufficient for high-latency networks or during network congestion.

Consider adding a configuration option for the timeout:

-	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+	timeout := 5 * time.Second
+	if config.TxGossipSequencerTimeout > 0 {
+		timeout = config.TxGossipSequencerTimeout
+	}
+	ctx, cancel := context.WithTimeout(context.Background(), timeout)

Additionally, consider validating the HTTP endpoint format before attempting the connection to provide better error messages.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a43881d and 7f3ae1d.

📒 Files selected for processing (8)
  • cmd/geth/main.go (1 hunks)
  • cmd/geth/usage.go (1 hunks)
  • cmd/utils/flags.go (2 hunks)
  • eth/api_backend.go (4 hunks)
  • eth/backend.go (5 hunks)
  • eth/ethconfig/config.go (1 hunks)
  • eth/handler.go (4 hunks)
  • eth/handler_eth.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: test
  • GitHub Check: check
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (go)
🔇 Additional comments (16)
eth/ethconfig/config.go (1)

234-236: LGTM! Clean configuration additions.

The new configuration fields for transaction gossip control are well-named, properly typed, and appropriately placed in the Config struct.

eth/handler_eth.go (1)

59-61: LGTM! Correct implementation of transaction receiving control.

The early return when disableTxReceiving is true ensures that transaction receiving can be completely disabled, which aligns with the PR objective.

cmd/geth/main.go (1)

179-181: LGTM! Proper CLI flag integration.

The three transaction gossip control flags are correctly added to the node configuration flags, making them available as command-line options.

eth/handler.go (4)

97-98: LGTM! Clean configuration structure additions.

The new fields for controlling transaction gossip behavior are properly added to the handler configuration.


138-139: LGTM! Proper field additions to handler struct.

The transaction gossip control fields are correctly added to the handler struct.


159-160: LGTM! Correct field initialization.

The configuration fields are properly initialized in the handler constructor.


425-430: LGTM! Proper conditional initialization of transaction broadcast.

The transaction broadcast loop initialization is correctly guarded by the disableTxBroadcast flag, preventing unnecessary resource allocation when broadcasting is disabled.

eth/backend.go (4)

112-114: LGTM: Sequencer RPC service field addition.

The new seqRPCService field is properly typed and documented. The placement within the "Scroll additions" section is appropriate.


289-290: LGTM: Handler configuration for transaction gossip control.

The new configuration flags for disabling transaction broadcast and receiving are properly integrated into the handler configuration.


300-300: LGTM: EthAPIBackend initialization with transaction gossip flag.

The addition of config.TxGossipReceivingDisabled parameter properly integrates the new transaction pool control functionality.


693-695: LGTM: Proper resource cleanup for sequencer RPC service.

The cleanup logic correctly checks for nil and closes the RPC client to prevent resource leaks.

eth/api_backend.go (3)

28-28: LGTM: Required imports for sequencer functionality.

The added imports for hexutil and log are necessary for transaction encoding and logging in the new sequencer forwarding logic.

Also applies to: 39-39


49-49: LGTM: Transaction pool control field addition.

The disableTxPool field provides clear control over local transaction pool behavior.


295-298: LGTM: Clean encapsulation of local transaction pool logic.

The sendTx helper method properly encapsulates the transaction pool addition logic with appropriate validation.

cmd/utils/flags.go (2)

896-909: LGTM: Well-structured flag definitions.

The three new transaction gossip flags are properly defined with clear names, appropriate types, and descriptive usage strings. The flag naming follows the established conventions in the codebase.


1807-1814: LGTM: Correct flag-to-config mapping with appropriate logging.

The boolean flag assignments are implemented correctly, following the established pattern of other flags in this function. The informational logging provides useful visibility into the configuration state.

@yiweichi yiweichi changed the title Feat/forward txs to sequencer feat: forward txs to sequencer Jun 19, 2025
colinlyguo
colinlyguo previously approved these changes Jun 20, 2025
@colinlyguo colinlyguo self-requested a review June 20, 2025 21:24
colinlyguo
colinlyguo previously approved these changes Jun 30, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
eth/api_backend.go (1)

267-297: Review error handling and transaction flow logic.

The SendTx method has the same concerning behavior patterns identified in previous reviews:

  1. Blob transaction rejection timing: Blob transactions are rejected before attempting sequencer forwarding, which prevents forwarding even if the sequencer supports them.

  2. Error suppression concern: When sequencer forwarding succeeds but local pool addition fails, the error is logged as a warning and nil is returned, potentially misleading users.

The suggested alternative flow from the previous review remains valid and should be implemented.

🧹 Nitpick comments (1)
eth/api_backend.go (1)

49-49: Consider consistent field alignment.

The disableTxPool field should be aligned with the other fields in the struct for better code consistency.

 type EthAPIBackend struct {
 	extRPCEnabled       bool
 	allowUnprotectedTxs bool
-	disableTxPool		bool
+	disableTxPool       bool
 	eth                 *Ethereum
 	gpo                 *gasprice.Oracle
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d6f953 and d23b71f.

📒 Files selected for processing (2)
  • eth/api_backend.go (4 hunks)
  • params/version.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • params/version.go
🧰 Additional context used
🧠 Learnings (1)
eth/api_backend.go (1)
Learnt from: Thegaram
PR: scroll-tech/go-ethereum#1204
File: miner/scroll_worker.go:836-845
Timestamp: 2025-06-11T15:54:05.820Z
Learning: When `processTxn` rejects a transaction because its calculated L1 data fee is ≥ `fees.MaxL1DataFee()`, this indicates a mis-configured system parameter, not a bad transaction, so the tx must remain in the TxPool rather than being purged.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (go)
🔇 Additional comments (2)
eth/api_backend.go (2)

28-28: LGTM: Required imports added correctly.

The hexutil and log imports are properly added to support the new transaction forwarding functionality.

Also applies to: 39-39


299-302: LGTM: Helper method is well-implemented.

The sendTx helper method properly encapsulates the local transaction pool logic and maintains the existing validation behavior.

colinlyguo
colinlyguo previously approved these changes Jul 8, 2025
Copy link
Member

@colinlyguo colinlyguo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yiweichi
Copy link
Member Author

yiweichi commented Jul 8, 2025

lgtm. There's a CI failure here: https://github.com/scroll-tech/go-ethereum/actions/runs/16101769286/job/45431817487.

This looks like a long-existing CI issue we used to have. I remember I discussed this with Hongfan, and we either ignore this CI failure or remove it.

@colinlyguo
Copy link
Member

colinlyguo commented Jul 8, 2025

lgtm. There's a CI failure here: https://github.com/scroll-tech/go-ethereum/actions/runs/16101769286/job/45431817487.

This looks like a long-existing CI issue we used to have. I remember I discussed this with Hongfan, and we either ignore this CI failure or remove it.

Can still run goimport and ignore changes in other files. there're some reasonable fixes e.g., ae97f0d and 8711560.

@yiweichi yiweichi requested review from jonastheis and colinlyguo July 9, 2025 18:58
@yiweichi yiweichi merged commit b0619ce into develop Jul 14, 2025
4 checks passed
@yiweichi yiweichi deleted the feat/forward-txs-to-sequencer branch July 14, 2025 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants